import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicHttpRequest;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.io.InputStream;

public class HttpClientDemo {
    public static void main(String[] args) {
        try(CloseableHttpClient client = HttpClientBuilder.create().build()){
            HttpHost httpHost = new HttpHost("127.0.0.1",8888,"http");
            HttpRequest httpRequest = new BasicHttpRequest("GET","/format/date");
            CloseableHttpResponse closeableHttpResponse = client.execute(httpHost, httpRequest);

            String result = EntityUtils.toString(closeableHttpResponse.getEntity());
            System.out.println(result);
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
